
<style lang="less">
.count-style {
  font-size: 50px;
}
</style>
<template>
  <div>
    <Row :gutter="20" v-if="!isEmployee">
      <center>
        <img style="width:40%" src="@/assets/images/logo_title_black.png" />
      </center>
    </Row>
    <Row :gutter="20" v-if="isEmployee">
      <i-col
        :xs="12"
        :md="8"
        :lg="8"
        v-for="(infor, i) in inforCardData"
        :key="`infor-${i}`"
        style="height: 120px;padding-bottom: 10px;"
      >
        <infor-card shadow :color="infor.color" :icon="infor.icon" :icon-size="36">
          <count-to :end="infor.count" count-class="count-style" />
          <p>{{ infor.title }}</p>
        </infor-card>
      </i-col>
    </Row>
  </div>
</template>

<script>
import InforCard from "_c/info-card";
import CountTo from "_c/count-to";
import { ChartPie, ChartBar } from "_c/charts";
import { GetCount } from "@/api/data";
import { getUserInfo } from "@/libs/util";
export default {
  name: "home",
  components: {
    InforCard,
    CountTo
  },
  data() {
    return {
      isEmployee: false,
      inforCardData: [
        { title: "待评估", icon: "ios-body", count: 0, color: "#2d8cf0" },
        { title: "已评估", icon: "md-body", count: 0, color: "#19be6b" },
        { title: "新增评估人员", icon: "ios-man", count: 0, color: "#ff9900" },
        { title: "待核查", icon: "ios-body", count: 0, color: "#2d8cf0" },
        { title: "已核查", icon: "md-body", count: 0, color: "#19be6b" },
        { title: "新增核查人员", icon: "ios-man", count: 0, color: "#ff9900" }
      ]
    };
  },
  methods: {
    GetCount() {
      let vm = this;
      var user = getUserInfo();
      if (user.Type == 1) {
        vm.isEmployee = false;
        this.$router.push({
          name: "area_saved"
        });
        return;
      }
      vm.isEmployee = true;
      GetCount().then(res => {
        const data = res.data;
        if (data.Type == 1) {
          vm.$set(vm.inforCardData, 0, {
            title: "待评估",
            icon: "ios-body",
            count: data.Data.count1,
            color: "#2d8cf0"
          });
          vm.$set(vm.inforCardData, 1, {
            title: "已评估",
            icon: "md-body",
            count: data.Data.count2,
            color: "#19be6b"
          });
          vm.$set(vm.inforCardData, 2, {
            title: "新增评估人员",
            icon: "ios-man",
            count: data.Data.count3,
            color: "#ff9900"
          });
            vm.$set(vm.inforCardData, 3, { title: "待核查", icon: "ios-body", count: data.Data.count4, color: "#2d8cf0" });
            vm.$set(vm.inforCardData, 4,  { title: "已核查", icon: "md-body", count: data.Data.count5, color: "#19be6b" });
            vm.$set(vm.inforCardData, 5,  { title: "新增核查人员", icon: "ios-man", count: data.Data.count6, color: "#ff9900" });
        }
      });
    }
  },
  mounted() {
    this.GetCount();
  }
};
</script>

